
find_package(XercesC REQUIRED)

INCLUDE_DIRECTORIES(${MATLAB_INCLUDE_DIR} ${ISMRMRD_INCLUDE_DIR} ${ISMRMRD_XSD_INCLUDE_DIR} ${Boost_INCLUDE_DIR})
add_library(DoMatToHDF5 SHARED DoMatToHDF5.cpp ${CMAKE_SOURCE_DIR}/Matlabdef.def ${ISMRMRD_XSD_SOURCE})
target_link_libraries(DoMatToHDF5 ${MATLAB_LIBRARIES} ${ISMRMRD_LIBRARIES} ${XERCESC_LIBRARIES} ${Boost_LIBRARIES})

if(WIN32)
  if (CMAKE_CL_64)
      SET_TARGET_PROPERTIES(DoMatToHDF5 PROPERTIES SUFFIX .mexw64)
  else(CMAKE_CL_64)
      SET_TARGET_PROPERTIES(DoMatToHDF5 PROPERTIES SUFFIX .mexw32)
  endif(CMAKE_CL_64)
else(WIN32)
  if (CMAKE_SIZEOF_VOID_P MATCHES "8")
      SET_TARGET_PROPERTIES(DoMatToHDF5 PROPERTIES SUFFIX .mexa64 PREFIX "") 
  else(CMAKE_SIZEOF_VOID_P MATCHES "8")
      SET_TARGET_PROPERTIES(DoMatToHDF5 PROPERTIES SUFFIX .mexglx PREFIX "")
  endif (CMAKE_SIZEOF_VOID_P MATCHES "8")
endif(WIN32)

install(TARGETS DoMatToHDF5 DESTINATION ../bin)